class Solution {
public:
    int maxArea(vector<int>& height) {
        if(height.size() < 2) return 0;
        int left = 0, right = height.size()-1, res = 0;
        while(left < right)
        {
            int capacity = min(height[left], height[right]) * (right - left);\
            res = max(capacity, res);
            if(height[left] < height[right])
                left++;
            else
                right--;
        }
        return res;
    }
};